page.form = {};
page.form.init=function(){
	$('#onProductTime').datepicker({language: 'zh-CN',format: 'yyyy-mm-dd'});
	$('#omMarketTime').datepicker({language: 'zh-CN',format: 'yyyy-mm-dd'});
	$('#downProductTime').datepicker({language: 'zh-CN',format: 'yyyy-mm-dd'});
	$("#supplierSelectBtn").bind("click",function(){
		page.form.event.selectSupplier();
	});
};
page.form.event = {
	submit : function(dialog, callback,index) {
		// 校验
		$('#mainForm').validate();
		var validate = $('#mainForm').valid();
		if (validate) {
			var data = $('#mainForm').serialize() // 要提交的表单,必须使用name属性
			$.dataPost(contextPath + "/depot/material/add.htm", data,function(result) {
				if (result.success) {
					if (callback)callback();
					dialog.close(index);
				} else {
					layer.msg(result.msg);
				}
			});
		}

	},selectSupplier :function(){
		openIframeWindow("选择供应商",contextPath+"/depot/supplier/selectView.htm",{},function(node){
			 $("#supplierName").val(node.supplierName);
			 $("#supplierId").val(node.supplierId);
		  });
	}
}
